/**
 * PreferencesAction.java
 * @author: liuex
 * 2007-12-31 ����06:05:00
 *
 * note: 
 */
package lex.mtd.ui.actions;

import java.awt.event.ActionEvent;

import javax.swing.KeyStroke;
import javax.swing.SwingWorker;

import org.lex.swing.prefs.PreferencesDialog;
import org.lex.swing.prefs.TitleDecorator;

import lex.mtd.ui.prefs.GeneralCategory;

public class PreferencesAction extends BaseAction {
	public PreferencesAction() {
		this.setName("Preferences...");
		this.setMnemonic('P');
		this.setAcceleratorKey(KeyStroke.getKeyStroke("F6"));
	}

	public void actionPerformed( ActionEvent e )
	{
		new SwingWorker<PreferencesDialog, Void>(){
			@Override
			protected PreferencesDialog doInBackground() throws Exception
			{
				PreferencesDialog d = new PreferencesDialog( getRoot() );
				d.loadCategories( TitleDecorator.decorate( new GeneralCategory() ) );
				d.setSize( 425, 375 );
				d.setLocationRelativeTo( getRoot() );
				return d;
			}

			@Override
			protected void done()
			{
				try
				{
					this.get().setVisible( true );
				}
				catch( Exception e )
				{
					e.printStackTrace();
				}
			}
		}.execute();
	}
}
